using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows.Forms;

namespace NEAnnotation
{
	/// <summary>
	/// Summary description for UCAttribute.
	/// </summary>
	public class UCAttribute : System.Windows.Forms.UserControl
	{
		private System.Windows.Forms.ComboBox cmbAttribute;
		private System.Windows.Forms.Label lbAttribute;
		private ArrayList arrDescription;
		/// <summary> 
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;

		public UCAttribute()
		{
			// This call is required by the Windows.Forms Form Designer.
			InitializeComponent();

			// TODO: Add any initialization after the InitializeComponent call

		}
		public string AttributeName{
			get{
				return lbAttribute.Text.Substring(1);
			}
			set{
				lbAttribute.Text = "&" + value;
			}
		}
		public string AttributeValue
		{
			get
			{
				if(cmbAttribute.SelectedIndex > 0)
					return cmbAttribute.SelectedItem.ToString();
				return "";
			}
			set
			{
				for (int i = 0; i< cmbAttribute.Items.Count; i++)
				{
					if(cmbAttribute.Items[i].ToString() == value)
					{
						cmbAttribute.SelectedIndex = i;
						break;
					}

				}
				
			}
		}
		public string AttributeValues
		{
			get
			{
				string stTemp = "";
				for (int i = 0; i< cmbAttribute.Items.Count; i++)
					stTemp += cmbAttribute.Items[i].ToString();
	
				return stTemp;
			}
			set
			{
				if(value != "")
				{
					cmbAttribute.Text = "&" + lbAttribute.Text;
					arrDescription = new ArrayList();

					cmbAttribute.Items.Clear();
					cmbAttribute.Items.Add("null");
					string[] stValues = value.Trim('#').Split('#');
					foreach(string stValue in stValues)
					{
						cmbAttribute.Items.Add(stValue);
					
					}
					
					if(cmbAttribute.Items.Count > 0)
						cmbAttribute.SelectedIndex = 0;
					cmbAttribute.Enabled = true;
				}
				
			
			}
		}

		/// <summary> 
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Component Designer generated code
		/// <summary> 
		/// Required method for Designer support - do not modify 
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			this.lbAttribute = new System.Windows.Forms.Label();
			this.cmbAttribute = new System.Windows.Forms.ComboBox();
			this.SuspendLayout();
			// 
			// lbAttribute
			// 
			this.lbAttribute.ForeColor = System.Drawing.Color.Blue;
			this.lbAttribute.Location = new System.Drawing.Point(8, 8);
			this.lbAttribute.Name = "lbAttribute";
			this.lbAttribute.Size = new System.Drawing.Size(80, 24);
			this.lbAttribute.TabIndex = 0;
			this.lbAttribute.Text = "lbAttribute";
			this.lbAttribute.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
			// 
			// cmbAttribute
			// 
			this.cmbAttribute.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
				| System.Windows.Forms.AnchorStyles.Right)));
			this.cmbAttribute.BackColor = System.Drawing.SystemColors.Window;
			this.cmbAttribute.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
			this.cmbAttribute.Location = new System.Drawing.Point(88, 8);
			this.cmbAttribute.Name = "cmbAttribute";
			this.cmbAttribute.Size = new System.Drawing.Size(88, 24);
			this.cmbAttribute.TabIndex = 1;
			this.cmbAttribute.KeyDown += new System.Windows.Forms.KeyEventHandler(this.cmbAttribute_KeyDown);
			this.cmbAttribute.SelectedIndexChanged += new System.EventHandler(this.cmbAttribute_SelectedIndexChanged);
			// 
			// UCAttribute
			// 
			this.Controls.Add(this.cmbAttribute);
			this.Controls.Add(this.lbAttribute);
			this.Font = new System.Drawing.Font("Tahoma", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.Name = "UCAttribute";
			this.Size = new System.Drawing.Size(184, 40);
			this.ResumeLayout(false);

		}
		#endregion

		private void cmbAttribute_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
		{
			
			switch (e.KeyValue)
			{
				case 13:
					break;
				case 8:
					break;
				case 40:
					if(cmbAttribute.DroppedDown == false)
						cmbAttribute.DroppedDown = true; 
					break;
				case 189:	
					if (e.Shift)
					{
					}
					break;
			}
		}

		private void cmbAttribute_SelectedIndexChanged(object sender, System.EventArgs e)
		{
			
		}
	}
}
